﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using wpffc.contracts.domaindata;
using wpffc.contracts.infrastructure;
using wpffc.contracts.viewmodels.learning;
using wpffc.flashcardbox;
using wpffc.viewmodelmapping;
using wpffc.views;

namespace wpffc.app
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            // Build
            var boxContainer = new SharedState<IFlashCardBox>();

            var lvm = new LearningViewModel();
            var open = new Open_box();
            var adv = new Advance_card();
            var refill = new Refill_batch();
            var next = new Get_next_card();
            var learn = new Learn(adv, refill, next);
            var map = new Map_card_to_learningVM();
            var lv = new LearningView();

            // Bind
            lvm.ScoreKnowledgeCmd.Out_Execute += learn.Process_answer;

            open.Continue += learn.Start_learning;
            learn.NextCardToLearn += map.Process;

            // Inject
            open.Inject(boxContainer);
            adv.Inject(boxContainer);
            next.Inject(boxContainer);

            lv.Inject(lvm);
            map.Inject(lvm);

            // Config
            open.Configure(e.Args);

            // Run
            lv.Run(e.Args);
        }
    }
}
